/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yy.bugzilla.desk;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;

/**
 *
 * @author Alan
 */
public class WelcomePane {

    public static final String WELCOME = "Welcome";
    private MainApp mainApp;
    private Pane contextPane;

    public WelcomePane(MainApp mainApp) {
        this.mainApp = mainApp;
    }

    public Pane getContextPane() {
        if (contextPane == null) {
            contextPane = generatePane();
        }
        return contextPane;
    }

    private Pane generatePane() {
        Text welcomeText = new Text("Welcome to\nBugzilla Desk Management");
        welcomeText.setTextAlignment(TextAlignment.CENTER);
        welcomeText.setStyle("-fx-font: 50px Tahoma;\n"
                + "-fx-fill: linear-gradient(from 0% 0% to 0% 80%, gray, darkgray 50%, aqua 99%, white);\n"
                + "-fx-stroke: black;\n"
                + "-fx-stroke-width: 1;");
        welcomeText.setEffect(new DropShadow());

        Button button = new Button("Click here to config a Bugzilla Server.");
        button.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent t) {
                mainApp.getMainTabPane().addTab(ServerConfigPane.SERVER_CONFIG, new ServerConfigPane().getContextPane(), true);
            }
        });

        VBox vBox = new VBox();
        vBox.setSpacing(50);
        vBox.setAlignment(Pos.CENTER);
        vBox.getChildren().addAll(welcomeText, button);
        return vBox;
    }
}
